/*
Navicat PGSQL Data Transfer

Source Server         : test
Source Server Version : 90303
Source Host           : localhost:5432
Source Database       : testMZ
Source Schema         : public

Target Server Type    : PGSQL
Target Server Version : 90303
File Encoding         : 65001

Date: 2014-06-15 21:52:00
*/


-- ----------------------------
-- Sequence structure for "ierarchy_id_seq"
-- ----------------------------
CREATE SEQUENCE "ierarchy_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 11
 CACHE 1;

-- ----------------------------
-- Sequence structure for "input_id_seq"
-- ----------------------------
CREATE SEQUENCE "input_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 26
 CACHE 1;

-- ----------------------------
-- Sequence structure for "internal_id_seq"
-- ----------------------------
CREATE SEQUENCE "internal_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 32
 CACHE 1;

-- ----------------------------
-- Sequence structure for "output_id_seq"
-- ----------------------------
CREATE SEQUENCE "output_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Sequence structure for "valves_id_seq"
-- ----------------------------
CREATE SEQUENCE "valves_id_seq"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 5
 CACHE 1;

-- ----------------------------
-- Table structure for "ierarchy"
-- ----------------------------
CREATE TABLE "ierarchy" (
"id" int4 DEFAULT nextval('ierarchy_id_seq'::regclass) NOT NULL,
"p_id" int4 NOT NULL,
"c_id" int4 NOT NULL,
"p_o" int4 NOT NULL,
"c_i" int4 NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of ierarchy
-- ----------------------------
BEGIN;
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('3', '1', '2', '1', '1');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('4', '1', '8', '1', '1');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('5', '5', '8', '4', '2');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('6', '1', '2', '2', '2');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('7', '2', '3', '1', '1');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('8', '2', '3', '2', '2');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('9', '4', '5', '1', '1');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('10', '5', '6', '1', '1');
INSERT INTO "ierarchy" ("id", "p_id", "c_id", "p_o", "c_i") VALUES ('11', '7', '6', '1', '2');
COMMIT;

-- ----------------------------
-- Table structure for "input"
-- ----------------------------
CREATE TABLE "input" (
"id" int4 DEFAULT nextval('input_id_seq'::regclass) NOT NULL,
"v_id" int4 NOT NULL,
"num" int4 NOT NULL,
"status" bool NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of input
-- ----------------------------
BEGIN;
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('1', '1', '1', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('2', '2', '1', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('3', '2', '2', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('4', '2', '3', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('5', '2', '4', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('6', '3', '1', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('7', '3', '2', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('8', '3', '3', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('9', '3', '4', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('10', '4', '1', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('11', '4', '2', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('12', '4', '3', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('13', '4', '4', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('14', '5', '1', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('15', '5', '2', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('16', '5', '3', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('17', '5', '4', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('18', '6', '1', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('19', '6', '2', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('20', '6', '3', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('21', '6', '4', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('22', '7', '1', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('23', '7', '2', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('24', '7', '3', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('25', '7', '4', 't');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('26', '8', '1', 'f');
INSERT INTO "input" ("id", "v_id", "num", "status") VALUES ('27', '8', '2', 't');
COMMIT;

-- ----------------------------
-- Table structure for "internal"
-- ----------------------------
CREATE TABLE "internal" (
"id" int4 DEFAULT nextval('internal_id_seq'::regclass) NOT NULL,
"v_id" int4 NOT NULL,
"in" int4 NOT NULL,
"out" int4 NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of internal
-- ----------------------------
BEGIN;
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('1', '1', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('3', '1', '1', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('4', '1', '1', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('5', '1', '1', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('6', '2', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('7', '2', '2', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('8', '2', '3', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('9', '2', '4', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('10', '3', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('11', '3', '2', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('12', '3', '3', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('13', '3', '4', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('14', '4', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('15', '4', '2', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('16', '4', '3', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('17', '4', '4', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('18', '5', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('19', '5', '2', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('20', '5', '3', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('21', '5', '4', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('22', '6', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('23', '6', '2', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('24', '6', '3', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('25', '6', '4', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('26', '7', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('27', '7', '2', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('28', '7', '3', '3');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('29', '7', '4', '4');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('30', '8', '1', '1');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('31', '8', '2', '2');
INSERT INTO "internal" ("id", "v_id", "in", "out") VALUES ('32', '8', '2', '3');
COMMIT;

-- ----------------------------
-- Table structure for "output"
-- ----------------------------
CREATE TABLE "output" (
"id" int4 DEFAULT nextval('output_id_seq'::regclass) NOT NULL,
"v_id" int4 NOT NULL,
"num" int4 NOT NULL,
"status" bool NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of output
-- ----------------------------
BEGIN;
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('1', '1', '1', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('2', '1', '2', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('3', '1', '3', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('4', '1', '4', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('5', '2', '1', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('6', '2', '2', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('7', '2', '3', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('8', '2', '4', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('9', '3', '1', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('10', '3', '2', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('11', '3', '3', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('12', '3', '4', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('13', '4', '1', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('14', '4', '2', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('15', '4', '3', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('16', '4', '4', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('17', '5', '1', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('18', '5', '2', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('19', '5', '3', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('20', '5', '4', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('21', '6', '1', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('22', '6', '2', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('23', '6', '3', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('24', '6', '4', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('25', '7', '1', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('26', '7', '2', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('27', '7', '3', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('28', '7', '4', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('29', '8', '1', 't');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('30', '8', '2', 'f');
INSERT INTO "output" ("id", "v_id", "num", "status") VALUES ('31', '8', '3', 't');
COMMIT;

-- ----------------------------
-- Table structure for "valves"
-- ----------------------------
CREATE TABLE "valves" (
"id" int4 DEFAULT nextval('valves_id_seq'::regclass) NOT NULL,
"v_name" text NOT NULL,
"input" int4 NOT NULL,
"output" int4 NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Records of valves
-- ----------------------------
BEGIN;
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('1', 'k1', '1', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('2', 'k2', '4', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('3', 'k3', '4', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('4', 'k4', '4', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('5', 'k5', '4', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('6', 'k6', '4', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('7', 'k7', '4', '4');
INSERT INTO "valves" ("id", "v_name", "input", "output") VALUES ('8', 'k8', '2', '3');
COMMIT;

-- ----------------------------
-- Alter Sequences Owned By 
-- ----------------------------
ALTER SEQUENCE "ierarchy_id_seq" OWNED BY "ierarchy"."id";
ALTER SEQUENCE "input_id_seq" OWNED BY "input"."id";
ALTER SEQUENCE "internal_id_seq" OWNED BY "internal"."id";
ALTER SEQUENCE "output_id_seq" OWNED BY "output"."id";
ALTER SEQUENCE "valves_id_seq" OWNED BY "valves"."id";

-- ----------------------------
-- Uniques structure for table "ierarchy"
-- ----------------------------
ALTER TABLE "ierarchy" ADD UNIQUE ("c_id", "c_i");

-- ----------------------------
-- Primary Key structure for table "ierarchy"
-- ----------------------------
ALTER TABLE "ierarchy" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Uniques structure for table "input"
-- ----------------------------
ALTER TABLE "input" ADD UNIQUE ("v_id", "num");

-- ----------------------------
-- Primary Key structure for table "input"
-- ----------------------------
ALTER TABLE "input" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Uniques structure for table "internal"
-- ----------------------------
ALTER TABLE "internal" ADD UNIQUE ("v_id", "in", "out");

-- ----------------------------
-- Primary Key structure for table "internal"
-- ----------------------------
ALTER TABLE "internal" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Uniques structure for table "output"
-- ----------------------------
ALTER TABLE "output" ADD UNIQUE ("v_id", "num");

-- ----------------------------
-- Primary Key structure for table "output"
-- ----------------------------
ALTER TABLE "output" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Uniques structure for table "valves"
-- ----------------------------
ALTER TABLE "valves" ADD UNIQUE ("v_name");

-- ----------------------------
-- Primary Key structure for table "valves"
-- ----------------------------
ALTER TABLE "valves" ADD PRIMARY KEY ("id");

-- ----------------------------
-- Foreign Key structure for table "ierarchy"
-- ----------------------------
ALTER TABLE "ierarchy" ADD FOREIGN KEY ("p_id") REFERENCES "valves" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "ierarchy" ADD FOREIGN KEY ("c_id") REFERENCES "valves" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "input"
-- ----------------------------
ALTER TABLE "input" ADD FOREIGN KEY ("v_id") REFERENCES "valves" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "internal"
-- ----------------------------
ALTER TABLE "internal" ADD FOREIGN KEY ("v_id") REFERENCES "valves" ("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "output"
-- ----------------------------
ALTER TABLE "output" ADD FOREIGN KEY ("v_id") REFERENCES "valves" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
